
class User {
  static GENERAL = 0
  static ADMIN = 1

  static types = {
    ENDUSER: 0,
    OPERATOR: 1
  }

  static typeList = [
    {value: User.types.OPERATOR, name: '运营用户'}
  ]

  static toName (type) {
    for (var index in User.typeList) {
      if (User.typeList[index].value === type) {
        return User.typeList[index].name
      }
    }
    return ''
  }

  static isAdmin (value) {
    return value === User.ADMIN
  }

  static SEX_NONE = 0
  static MALE = 1
  static FEMALE = 2

  static getSexName (sex) {
    if (sex === User.MALE) {
      return '男'
    } else if (sex === User.FEMALE) {
      return '女'
    } else if (sex === User.SEX_NONE) {
      return '未知'
    } else {
      return sex
    }
  }

  static adminToName (value) {
    return User.isAdmin(value) ? '管理员' : '普通用户'
  }
}

export default User
